1688C - Manipulating History - CodeForces Solution


constructive algorithms greedy strings *1700

Please click on ads to support us..

Python Code:

from collections import Counter
for t in range(int(input())):
    n = int(input())
    s = ""
    for i in range(2*n+1):
        s += input()
    s = Counter(s)
    for x,y in s.items():
        if(y%2):print(x); break

C++ Code:

#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<char, int> mci;
 
#define f first
#define s second
#define mp make_pair
 
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) x.size()
 
const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const int MAX = 1e7;

void solve() {
    int n; cin >> n;
    char c = 0;
    n = n*2+1;
    while (n--) {
        string s;
        cin >> s;
        for (auto x : s) 
            c^=x;
    }
    cout << c << '\n';
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    int t; cin >> t;
    while (t--)
        solve();
	// solve(); 
	return 0;
}


Comments

Submit
0 Comments
More Questions

750A - New Year and Hurry
705A - Hulk
492B - Vanya and Lanterns
1374C - Move Brackets
1476A - K-divisible Sum
1333A - Little Artem
432D - Prefixes and Suffixes
486A - Calculating Function
1373B - 01 Game
1187A - Stickers and Toys
313B - Ilya and Queries
579A - Raising Bacteria
723A - The New Year Meeting Friends
302A - Eugeny and Array
1638B - Odd Swap Sort
1370C - Number Game
1206B - Make Product Equal One
131A - cAPS lOCK
1635A - Min Or Sum
474A - Keyboard
1343A - Candies
1343C - Alternating Subsequence
1325A - EhAb AnD gCd
746A - Compote
318A - Even Odds
550B - Preparing Olympiad
939B - Hamster Farm
732A - Buy a Shovel
1220C - Substring Game in the Lesson
452A - Eevee